home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Video_Chat2075237132007.psc / Video Chat / Clt / frmClt.frm < prev    next >
Text File  |  2007-07-13  |  11KB  |  298 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.Form frmClt 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "┐═╗º╢╦ Client"
  6.    ClientHeight    =   3345
  7.    ClientLeft      =   10800
  8.    ClientTop       =   300
  9.    ClientWidth     =   4560
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   3345
  13.    ScaleWidth      =   4560
  14.    Begin VB.CheckBox Check1 
  15.       Caption         =   "═╝╧≤╤╣╦⌡"
  16.       Height          =   180
  17.       Left            =   3360
  18.       TabIndex        =   7
  19.       Top             =   600
  20.       Width           =   1095
  21.    End
  22.    Begin VB.CommandButton Command4 
  23.       Caption         =   "▒╛╡╪═╝╧≤"
  24.       Height          =   375
  25.       Left            =   3480
  26.       TabIndex        =   6
  27.       Top             =   120
  28.       Width           =   975
  29.    End
  30.    Begin VB.CommandButton Command3 
  31.       Caption         =   "╢╘╖╜═╝╧≤"
  32.       Enabled         =   0   'False
  33.       Height          =   375
  34.       Left            =   2400
  35.       TabIndex        =   5
  36.       Top             =   120
  37.       Width           =   975
  38.    End
  39.    Begin VB.ListBox List1 
  40.       Height          =   2400
  41.       Left            =   120
  42.       TabIndex        =   4
  43.       Top             =   840
  44.       Width           =   4335
  45.    End
  46.    Begin VB.TextBox Text1 
  47.       Alignment       =   2  'Center
  48.       BorderStyle     =   0  'None
  49.       Height          =   180
  50.       Left            =   1440
  51.       TabIndex        =   2
  52.       Text            =   "127.0.0.1"
  53.       Top             =   600
  54.       Width           =   1815
  55.    End
  56.    Begin VB.CommandButton Command2 
  57.       Caption         =   "╢╧┐¬┴¼╜╙"
  58.       Enabled         =   0   'False
  59.       Height          =   375
  60.       Left            =   1320
  61.       TabIndex        =   1
  62.       Top             =   120
  63.       Width           =   975
  64.    End
  65.    Begin VB.CommandButton Command1 
  66.       Caption         =   "╜¿┴ó┴¼╜╙"
  67.       Height          =   375
  68.       Left            =   120
  69.       TabIndex        =   0
  70.       Top             =   120
  71.       Width           =   1095
  72.    End
  73.    Begin MSWinsockLib.Winsock Wsk1 
  74.       Left            =   0
  75.       Top             =   0
  76.       _ExtentX        =   741
  77.       _ExtentY        =   741
  78.       _Version        =   393216
  79.    End
  80.    Begin VB.Label Label1 
  81.       Caption         =   "╘╢│╠╝╞╦π╗·IPú║"
  82.       Height          =   180
  83.       Left            =   120
  84.       TabIndex        =   3
  85.       Top             =   600
  86.       Width           =   1260
  87.    End
  88. End
  89. Attribute VB_Name = "frmClt"
  90. Attribute VB_GlobalNameSpace = False
  91. Attribute VB_Creatable = False
  92. Attribute VB_PredeclaredId = True
  93. Attribute VB_Exposed = False
  94. Option Explicit
  95.  
  96. 'I'm a Chinese undergraduate student
  97. 'excuse my poor English ~_~!
  98. 'Code By TZWSOHO
  99.  
  100. Private Type ImageInfo
  101.     imgWidth As Long '┐φ╢╚width
  102.     imgHeight As Long '╕▀╢╚height
  103.     imgOrgSize As Long '═╝╧≤╘¡┤≤╨íoriginal size
  104.     imgCmpSize As Long '═╝╧≤╤╣╦⌡║≤┤≤╨ícompressed size
  105.     lBitCount As Long '═╝╧≤╬╗╔½╩²
  106.     lPtr As Long '╤╣╦⌡║≤╡─╓╕╒δcompressed pointer
  107. End Type
  108.  
  109. Private Declare Function SetDIBitsToDevice Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, ByRef Bits As Any, ByRef BitsInfo As BitMapInfo256, ByVal wUsage As Long) As Long
  110.  
  111. Private Sub Command1_Click()
  112. Wsk1.Close
  113. Wsk1.Connect Text1.Text, 8686
  114. End Sub
  115.  
  116. Private Sub Command2_Click()
  117. Wsk1.Close
  118. 'disconnect the connection with Wsk1.RemoteHostIP
  119. List1.AddItem "╙├╗º╢╧┐¬╙δ '" & Wsk1.RemoteHostIP & "' ╡─┴¼╜╙úí"
  120. Unload frmSelf
  121. Unload frmOpp
  122. Command1.Enabled = True
  123. Command2.Enabled = False
  124. Command3.Enabled = False
  125. End Sub
  126.  
  127. Private Sub Command3_Click()
  128. frmOpp.Show
  129. 'sending the commands of getting the images from the remote machine
  130. Wsk1.SendData Chr$(0) '╖ó╦═╗±╚í╘╢│╠╝╞╦π╗·╩╙╞╡═╝╧≤╡─├ⁿ┴ε
  131. Command3.Enabled = False
  132. End Sub
  133.  
  134. Private Sub Command4_Click()
  135. frmSelf.Show
  136. Call Get_CaptureWindow(0)
  137. End Sub
  138.  
  139. Private Sub Form_Unload(Cancel As Integer)
  140. Unload frmOpp
  141. Unload frmSelf
  142. Unload frmClt
  143. End
  144. End Sub
  145.  
  146. Private Sub Wsk1_Close()
  147. 'disconnected with the remote machine
  148. List1.AddItem "╥╤╛¡║═╘╢│╠╝╞╦π╗· '" & Wsk1.RemoteHostIP & "' ╢╧┐¬┴¼╜╙úí"
  149. Unload frmSelf
  150. Unload frmOpp
  151. Command1.Enabled = True
  152. Command2.Enabled = False
  153. Command3.Enabled = False
  154. End Sub
  155.  
  156. Private Sub Wsk1_Connect()
  157. 'connected the remote machine
  158. List1.AddItem "╥╤╛¡┴¼╜╙╔╧╘╢│╠╝╞╦π╗· '" & Wsk1.RemoteHostIP & "'úí"
  159. Command1.Enabled = False
  160. Command2.Enabled = True
  161. Command3.Enabled = True
  162. End Sub
  163.  
  164. Private Sub Wsk1_DataArrival(ByVal bytesTotal As Long)
  165. 'arrDIB ▒╛╡╪╩╙╞╡═╝╧≤╡─╨┼╧ó local images data
  166. 'arrDIBRec ╜╙╩╒╡╜╡─╘╢│╠╝╞╦π╗·╩╙╞╡═╝╧≤╨┼╧ó received remote images data
  167. On Error GoTo er
  168. Static bRecDIB As Boolean, dstImgInfo As ImageInfo
  169. Static arrDIB() As Byte, arrDIBRec() As Byte, BMPInfo As BitMapInfo256
  170. Dim srcImgInfo As ImageInfo
  171. Dim arrData() As Byte, I As Long
  172. Wsk1.GetData arrData, vbArray Or vbByte
  173. If bRecDIB Then
  174.     If ArrIsNull(arrDIBRec) Then
  175.         ReDim arrDIBRec(UBound(arrData))
  176.         Call CopyMemory(arrDIBRec(0), arrData(0), UBound(arrData) + 1)
  177.     Else
  178.         With dstImgInfo
  179.             If UBound(arrDIBRec) < .imgCmpSize - UBound(arrData) - 1 Then
  180.                 I = UBound(arrDIBRec) + 1
  181.                 ReDim Preserve arrDIBRec(I + UBound(arrData))
  182.                 Call CopyMemory(arrDIBRec(I), arrData(0), UBound(arrData) + 1)
  183.             Else
  184.                 'received the last array of data and make it
  185.                 'the background of frmOpp form
  186.                 '╜╙╩╒╫ε║≤╥╗╫Θ╩²╛▌▓ó┤≥╙í│╔ frmOpp ╡─▒│╛░
  187.                 I = UBound(arrDIBRec) + 1
  188.                 ReDim Preserve arrDIBRec(I + UBound(arrData))
  189.                 Call CopyMemory(arrDIBRec(I), arrData(0), UBound(arrData) + 1)
  190.                 BMPInfo = CreateBMInfo(.imgWidth, .imgHeight, .lBitCount)
  191.                 If .imgCmpSize < .imgOrgSize Then
  192.                     DoEvents
  193.                     Call Compress(arrDIBRec, .lPtr, .imgOrgSize) '╜Γ╤╣╦⌡═╝╧≤ decompress images
  194.                 End If
  195.                 Call SetDIBitsToDevice(frmOpp.hdc, 0, 0, .imgWidth, .imgHeight, 0, 0, 0, .imgHeight, arrDIBRec(0), BMPInfo, DIB_RGB_COLORS)
  196.                 DoEvents '▓╗╝╙╒Γ╛Σ╗¡├µ╜½╗ß▓╗┴≈│⌐ make the video fluent
  197.                 Erase arrDIBRec: bRecDIB = False
  198.                 Wsk1.SendData Chr$(1) '╝╠╨°╜╙╩╒╧┬╥╗╖∙═╝╧≤ receive the next image
  199.             End If
  200.         End With
  201.     End If
  202. Else
  203.     Select Case arrData(0)
  204.         Case 0 '╘╢│╠╝╞╦π╗·╥¬╟≤╜╙╩╒▒╛╡╪╝╞╦π╗·╡─╩╙╞╡═╝╧≤ requestion of receiving local video
  205.             List1.AddItem "╘╢│╠╝╞╦π╗·┐¬╩╝╜╙╩╒▒╛╡╪╩╙╞╡═╝╧≤..."
  206.             frmSelf.Show
  207.             Call Get_CaptureWindow(0)
  208.             Call Get_CaptureDIB(arrDIB, 8) '256╔½
  209.             With srcImgInfo
  210.                 .lBitCount = 8
  211.                 .imgOrgSize = UBound(arrDIB)
  212.                 .imgWidth = frmSelf.ScaleWidth
  213.                 .imgHeight = frmSelf.ScaleHeight - 20
  214.                 
  215.                 'the following line is for compressing the video
  216.                 '╧┬├µ╒Γ╥╗╨╨╩╟╤╣╦⌡═╝╧≤╡─╣²│╠ú¼
  217.                 '╛¡╬╥▓Γ╩╘╩╣╙├╧┬├µ╥╗╨╨║≤ CPU ╒╝╙├┬╩▒╚├╗╩╣╙├╩▒╕▀ 10% ╫≤╙╥úí
  218.                 '▓╗╣²╦╞║⌡╢╘╖╜╡─═╝╧≤╗ß║▄┐¿ú¼▓╗╠½═╞╝÷╩╣╙├
  219.                 
  220.                 If CBool(Check1.Value) Then Call Compress(arrDIB, .lPtr, UBound(arrDIB)) '╤╣╦⌡═╝╧≤
  221.                 
  222.                 .imgCmpSize = UBound(arrDIB) '╤╣╦⌡║≤╡─═╝╧≤┤≤╨íú¿├╗╤╣╦⌡╛═╡╚╙┌ imgOrgSizeú⌐
  223.                 '╖ó╦══╝╧≤╨┼╧ó send the video data
  224.                 Wsk1.SendData Chr$(2) & CStr(.lBitCount) & CStr(.lPtr) & "|" & CStr(.imgOrgSize) & "|" & CStr(.imgCmpSize) & "|" & CStr(.imgWidth) & "|" & CStr(.imgHeight)
  225.             End With
  226.         Case 1 '╘╢│╠╝╞╦π╗·╝╠╨°┐¬╩╝╜╙╩╒═╝╧≤ continue receiving video
  227.             Call Get_CaptureDIB(arrDIB, 8) '256╔½
  228.             If ArrIsNull(arrDIB) Then Exit Sub
  229.             With srcImgInfo
  230.                 .lBitCount = 8
  231.                 .imgOrgSize = UBound(arrDIB)
  232.                 .imgWidth = frmSelf.ScaleWidth
  233.                 .imgHeight = frmSelf.ScaleHeight - 20
  234.                 If CBool(Check1.Value) Then Call Compress(arrDIB, .lPtr, UBound(arrDIB)) '╤╣╦⌡═╝╧≤
  235.                 .imgCmpSize = UBound(arrDIB)
  236.                 '╖ó╦══╝╧≤╨┼╧ó send video data
  237.                 Wsk1.SendData Chr$(2) & CStr(.lBitCount) & CStr(.lPtr) & "|" & CStr(.imgOrgSize) & "|" & CStr(.imgCmpSize) & "|" & CStr(.imgWidth) & "|" & CStr(.imgHeight)
  238.             End With
  239.         Case 2 '╘╢│╠╝╞╦π╗·╖ó└┤═╝╧≤╨┼╧ó remote video data
  240.             Dim v As Variant
  241.             v = Split(Mid(StrConv(arrData, vbUnicode), 3), "|")
  242.             With dstImgInfo
  243.                 .lBitCount = CByte(Mid(StrConv(arrData, vbUnicode), 2, 1))
  244.                 .lPtr = CLng(v(0))
  245.                 .imgOrgSize = CLng(v(1))
  246.                 .imgCmpSize = CLng(v(2))
  247.                 .imgWidth = CLng(v(3))
  248.                 .imgHeight = CLng(v(4))
  249.                 If frmOpp.WindowState = vbMinimized Then
  250.                     Wsk1.SendData Chr$(8)
  251.                     Exit Sub
  252.                 Else
  253.                     frmOpp.Width = .imgWidth * Screen.TwipsPerPixelX + 90
  254.                     frmOpp.Height = .imgHeight * Screen.TwipsPerPixelY + 510
  255.                 End If
  256.             End With
  257.             bRecDIB = True
  258.             Wsk1.SendData Chr$(3) '╥╤╛¡╫╝▒╕║├╜╙╩╒╩╙╞╡═╝╧≤ ready to receive
  259.         Case 3 '╘╢│╠╝╞╦π╗·╥¬╟≤╜╙╩╒▒╛╡╪╩╙╞╡═╝╧≤═╝╞¼ remote requestion of receiving video
  260.             Wsk1.SendData arrDIB
  261.             Erase arrDIB
  262.         Case 4 '╘╢│╠╝╞╦π╗·═ú╓╣╜╙╩╒╩╙╞╡═╝╧≤ remote stop receiving video
  263.             List1.AddItem "╘╢│╠╝╞╦π╗·═ú╓╣╜╙╩╒╩╙╞╡═╝╧≤"
  264.             Erase arrDIB
  265.             Unload frmSelf
  266.         Case 5 '╘╢│╠╝╞╦π╗·═ú╓╣╖ó╦══╝╧≤ remote stop sending video
  267.             List1.AddItem "╘╢│╠╝╞╦π╗·═ú╓╣╖ó╦══╝╧≤"
  268.             Erase arrDIBRec
  269.             Unload frmOpp
  270.         Case 6 '╘╢│╠╝╞╦π╗·╘▌═ú╖ó╦══╝╧≤ remote pause on receiving video
  271.             List1.AddItem "╘╢│╠╝╞╦π╗·╘▌═ú╖ó╦══╝╧≤"
  272.             Erase arrDIBRec
  273.         Case 7 '╘╢│╠╝╞╦π╗·╤»╬╩╩╟╖±╝╠╨°╜╙╩╒═╝╧≤╨┼╧ó remote ask if continue receiving video
  274.             frmOpp.Show
  275.             'continue receiving remote video
  276.             Wsk1.SendData Chr$(1) '╖ó╦═╝╠╨°╗±╚í╘╢│╠╝╞╦π╗·╩╙╞╡═╝╧≤╡─├ⁿ┴ε
  277.             Command3.Enabled = False
  278.         Case 8 '╘▌═ú╜╙╩╒▒╛╡╪═╝╧≤ stop receiving local video
  279.             List1.AddItem "╘▌═ú╜╙╩╒▒╛╡╪═╝╧≤"
  280.             Erase arrDIB
  281.     End Select
  282. End If
  283. Exit Sub
  284. er:
  285. List1.AddItem "┤φ╬≤:" & Err.Description
  286. Debug.Print Err.Description
  287. End Sub
  288.  
  289. Private Function ArrIsNull(arr() As Byte) As Boolean
  290. On Error GoTo er
  291. Dim I As Long
  292. I = UBound(arr)
  293. ArrIsNull = False
  294. Exit Function
  295. er:
  296. ArrIsNull = True
  297. End Function
  298.